package com.mnt.gui.base.contorls;

import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import com.mnt.gui.base.contorls.executer.DialogExecuter;
import com.mnt.gui.base.contorls.view.SimpleDialogController;
import com.mnt.gui.base.contorls.view.SimpleLoadingDialogController;
import com.mnt.gui.base.contorls.view.TipDialogController;

/**
 * 
 * <p>
 * 对话框控件获取实例工厂
 * </p>
 * @author    Cico.Jiang
 * @version  2014年5月22日 下午5:04:00 Cico.Jiang .
 * @since   3.3
 */
public abstract class SimpleDialogFactory
{
	protected SimpleDialogFactory() {
		//empty
	}
	
	/**
	 * simple dialog
	 * 2014-7-14 mnt.cico
	 * 
	 * @param parentStage
	 * @param title
	 * @param content
	 * @param executer
	 */
	public static final void showSimpleDialog(Stage parentStage, String title, String content, final DialogExecuter executer) {
		final Stage stage = new Stage();
		stage.initModality(Modality.APPLICATION_MODAL);
		stage.initStyle(StageStyle.TRANSPARENT);
		stage.initOwner(parentStage);
		SimpleDialogController simpleDialogController = new SimpleDialogController(executer, stage);
		simpleDialogController.setTitle(title);
		simpleDialogController.setContent(content);
		Scene scene = new Scene(simpleDialogController);
		stage.setScene(scene);
		stage.showAndWait();
	}
	
	/**
	 * tip dialog
	 * 2014-7-14 mnt.cico
	 * @param parentStage
	 * @param title
	 * @param content
	 */
	public static final void showTipDialog(Stage parentStage, String title, String content) {
		final Stage stage = new Stage();
		stage.initModality(Modality.APPLICATION_MODAL);
		stage.initStyle(StageStyle.TRANSPARENT);
		stage.initOwner(parentStage);
		TipDialogController tipDialogController = new TipDialogController(stage);
		tipDialogController.setTitle(title);
		tipDialogController.setContent(content);
		Scene scene = new Scene(tipDialogController);
		stage.setScene(scene);
		stage.showAndWait();
	}
	
	/**
	 * show simple load util
	 * 2014-7-22 mnt.cico
	 * @param parentStage
	 * @param content
	 * @return
	 */
	public static final SimpleLoadingDialogController showLoadingDialog(Stage parentStage, String content) {
		final Stage stage = new Stage();
		stage.initModality(Modality.APPLICATION_MODAL);
		stage.initStyle(StageStyle.TRANSPARENT);
		stage.initOwner(parentStage);
		final SimpleLoadingDialogController result = new SimpleLoadingDialogController(stage);
		result.setContent(content);
		Scene scene = new Scene(result);
		stage.setScene(scene);
		return result;
	}
	
}
